<script lang="ts">
import { defineComponent } from "vue";
export default defineComponent({
  name: "famousItem",
});
</script>
<script setup lang="ts">
import { reactive, ref, toRefs, watch, inject } from "vue";
import { Router } from "@/utils/router";
import like1 from "@/package/famous-talk/static/like1.png";
import like2 from "@/package/famous-talk/static/like2.png";
import love1 from "@/package/famous-talk/static/love1.png";
import love2 from "@/package/famous-talk/static/love2.png";
import msg from "@/package/famous-talk/static/msg.png";
import share from "@/package/famous-talk/static/share.png";
import micro from "@/package/famous-talk/static/micro.png";
import ReplayContent from "./reply-content.vue";
import LoveItem1 from "./love-item1.vue";
import FavoriteItem from "./favorite-item.vue";
import { AppData } from "@/utils/app";
import { my_data } from "../../api/guider";
import { Account } from "@/utils/account";
const config: any = inject("likeConfig");
type dataType = {
  guider_name: string;
  city_name: string;
  pic_url: string;
  title: string;
  like_count: string;
  comment_count: string;
  favorite_count: string;
  id: string;
  guider_interview_like: string;
};
const props = defineProps<{ data: dataType; reloadList: Function }>();
const isLove = ref(false);
const isLike = ref(false);
const lickClick = () => {
  isLike.value = !isLike.value;
};
const toDetail = () => {
  Router.navigateTo(
    `/package/famous-talk/pages/detail/index?id=${props.data.id}`
  );
};
//评论弹窗 ------------------------------------
const ReplayContentref = ref<typeof ReplayContent>();
const replyClick = () => {
  config.istoLogin(oprate);
};
const oprate = () => {
  ReplayContentref.value?.show({
    nickname: "评论：" + props.data.title,
    relation_id: props.data.id,
    comment_id: "",
    type: 23,
  });
};
const confirm = () => {
  props.reloadList();
};

// ------------------------------------------
const {
  guider_name,
  city_name,
  title,
  like_count,
  favorite_count,
  id,
  comment_count,
} = toRefs(props.data);
const reload = () => {
  props.reloadList();
};
</script>

<template>
  <view class="wrap">
    <view class="imageWrap" @click="toDetail">
      <image :src="data.pic_url" mode="widthFix" />
      <view class="visite" v-if="guider_name">
        <view class="visiteImageWrap">
          <image :src="micro"  />
        </view>

        <view class="visiteWrod">被访人：{{ guider_name }}</view>
        <view class="visiteWrod ml">{{ city_name }}</view>
      </view>
    </view>

    <view class="word">
      {{ title }}
    </view>
    <view class="footer">
      <LoveItem1
        :id="props.data.id"
        :like_count="props.data.like_count"
        @love="reload"
      />
      <FavoriteItem
        :id="props.data.id"
        :favorite_count="props.data.favorite_count"
        @love="reload"
      />
      <view class="item" @click="replyClick">
        <image :src="msg" mode="scaleToFill"  />
        <text v-if="comment_count">{{ comment_count }}</text>
        <text v-else>评论</text>
      </view>
      <view class="item" @click="shareClick">
          <image :src="share" mode="scaleToFill" />
          <text openType="share">转发</text>
        <button class="button" openType="share" :data-id="id">
        
        </button>
      </view>
    </view>
    <ReplayContent ref="ReplayContentref" @confirm="confirm" />
  </view>
</template>

<style lang="scss">
.wrap {
  margin: 20rpx auto;
  width: 690rpx;
  background: #ffffff;
  border-radius: 20rpx;
  padding: 10rpx;
  box-sizing: border-box;
  .imageWrap {
    position: relative;
    width: 100%;
    height: 334rpx;
    border-radius: 20rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    > image {
      width: 100vw;
    }
    .visite {
      position: absolute;
      left: 0;
      top: 260rpx;
      padding: 0 30rpx;
      height: 44rpx;
      background: rgba(255, 255, 255, 0.8);
      border-radius: 0px 22rpx 22rpx 0px;
      backdrop-filter: blur(6px);
      box-sizing: border-box;
      display: flex;
      padding: 10rpx 30rpx;
      align-items: center;
      .visiteImageWrap {
        width: 28rpx;
        height: 28rpx;
        margin-right: 6rpx;
        overflow: hidden;
        image {
          width: 28rpx;
          height: 28rpx;
          object-fit: cover; /* 裁剪并覆盖到容器 */
        }
      }

      .visiteWrod {
        font-size: 24rpx;
        color: #333333;
        line-height: 44rpx;
      }
      .ml {
        margin-left: 20rpx;
      }
    }
  }
  .word {
    padding: 20rpx 0;
    font-size: 28rpx;
    color: #333333;
    line-height: 40rpx;
    display: -webkit-box;
    word-break: break-all;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2; // 你想要的行数
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .footer {
    border-top: 2rpx solid #eeeeee;
    padding: 10rpx 20rpx;
    display: flex;
    justify-content: space-between;
    .item {
      display: flex;
      align-items: center;
      position: relative;
      image {
        width: 36rpx;
        height: 36rpx;
        margin-right: 14rpx;
      }
      button {
        position: absolute;
        left: 0;
        top: 0;
        border: none;
        width: 98rpx;
        height: 36rpx;
        opacity: 0;
      }
      text {
        font-size: 24rpx;
        color: #666666;
        line-height: 34rpx;
      }
    }
  }
}
</style>
